package com.atguigu.gmall.user.service.impl;

import com.atguigu.gmall.common.utils.UserAuthUtils;
import com.atguigu.gmall.user.vo.UserAuthInfoVo;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.atguigu.gmall.user.entity.UserAddress;
import com.atguigu.gmall.user.service.UserAddressService;
import com.atguigu.gmall.user.mapper.UserAddressMapper;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *
 */
@Service
public class UserAddressServiceImpl extends ServiceImpl<UserAddressMapper, UserAddress>
    implements UserAddressService{


    /**
     * 获取用户地址
     * @return
     */
    @Override
    public List<UserAddress> getUserAddress() {
        UserAuthInfoVo info = UserAuthUtils.getUserAuthInfo();
        Long userId = info.getUserId();

        QueryWrapper<UserAddress> wrapper = new QueryWrapper<>();
        wrapper.eq("user_id",userId);
        List<UserAddress> addresses = baseMapper.selectList(wrapper);
        return addresses;
    }
}




